/*
 * RSInt.cpp
 *
 *  Created on: 2010/03/17
 *      Author: alexandre
 */

#include "RSInt.h"
#include "RSSerializer.h"

namespace Realsphere {
    RSInt::RSInt ( ) :
        RSValueElement ()
    {
        SetTag( RS_INT_TAG, false );
    }

    RSInt::RSInt ( const QString& rScopeId ) :
        RSValueElement ( rScopeId )
    {
        SetTag( RS_INT_TAG, false );
    }

    RSInt::RSInt ( const int& rValue ) :
        RSValueElement ()
    {
        SetTag( RS_INT_TAG, false );
        SetValue ( rValue, false );
    }

    RSInt::RSInt ( const QString& rScopeId, int& rValue ) :
            RSValueElement ( rScopeId )
    {
        SetTag( RS_INT_TAG, false );
        SetValue ( rValue, false );
    }

    RSValueType RSInt::ValueType () const
    {
        return RS_INT;
    }

    RSDataSize RSInt::SizeOf () const
    {
        return sizeof(int);
    }


    RSDataPointer RSInt::DataPointer()
    {
        return &mValue;
    }


    QString RSInt::ToString () const
    {
        return RSSerializer::serialize(mValue);
    }

    int RSInt::Value () const
    {
        return mValue;
    }

    void RSInt::SetValue ( const int& rValue, bool rEmit )
    {
        mValue = rValue;
        if ( rEmit )
            emit ValueChanged();
    }

    void RSInt::SetValue ( const RSInt& rValue, bool rEmit )
    {
        SetValue ( rValue.Value(), rEmit );
    }

    RSInt& RSInt::operator=( const int& rValue )
    {
        SetValue( rValue );
        return *this;
    }

    RSInt& RSInt::operator=( const RSInt& rValue )
    {
        SetValue( rValue );
        return *this;
    }
}
